package com.xnyzc.lhy.mis.controller.cmsapi.user;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.mis.entity.param.cms.OfficeParam;
import com.xnyzc.lhy.mis.entity.param.cms.user.SupplierSeparateAccountParam;
import com.xnyzc.lhy.mis.entity.param.cms.user.SysDriverManagerParam;
import com.xnyzc.lhy.mis.entity.param.cms.user.SysUserParam;
import com.xnyzc.lhy.mis.entity.system.OaSysUserSeparateAccount;
import com.xnyzc.lhy.mis.service.cms.user.SysUserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户管理相关
 *
 * @Author: wangshuo
 * @Date: 2019-08-07 14:11
 */
@RestController
@RequestMapping("/cmsapi/user")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    /**
     * 系统用户管理列表
     *
     * @return
     */
    @ApiOperation(value = "系统用户管理列表", notes = "系统用户管理列表")
    @PostMapping(value = "/getSysUserList")
    public Rv getSysUserList(
            @ApiParam(name = "officeParam", value = "接入传参") @RequestBody OfficeParam officeParam) {
        return Rv.wrap(sysUserService.getSysUserList(officeParam));
    }

    /**
     * 系统用户管理列表(获取已开通城市)
     *
     * @return
     */
    @ApiOperation(value = "系统用户管理列表(获取已开通城市)", notes = "系统用户管理列表(获取已开通城市)")
    @GetMapping(value = "/getSysOpenCity")
    public Rv getSysOpenCity() {
        return Rv.wrap(sysUserService.getSysOpenCity());
    }

    /**
     * 系统用户管理列表全部城市
     *
     * @return
     */
    @ApiOperation(value = "系统用户管理列表全部城市", notes = "系统用户管理列表全部城市")
    @GetMapping(value = "/getSysAllCity")
    public Rv getSysAllCity() {
        return Rv.wrap(sysUserService.getSysAllCity());
    }

    /**
     * 用户、司机详情
     *
     * @return
     */
    @ApiOperation(value = "用户、司机详情", notes = "用户、司机详情")
    @PostMapping(value = "/getUserDetails")
    public Rv getUserDetails(@ApiParam(name = "officeParam", value = "接入传参") @RequestBody OfficeParam officeParam) {
        return Rv.wrap(sysUserService.getUserDetails(officeParam));
    }

    /**
     * 修改账号状态
     *
     * @return
     */
    @ApiOperation(value = "修改账号状态", notes = "修改账号状态")
    @PostMapping(value = "/getUpdateSysUserStatus")
    public Rv getUpdateSysUserStatus(
            @ApiParam(name = "officeParam", value = "接入传参") @RequestBody OfficeParam officeParam) {
        return Rv.wrap(sysUserService.getUpdateSysUserStatus(officeParam));
    }

    /**
     * 管理员详情
     *
     * @return
     */
    @ApiOperation(value = "管理员详情", notes = "管理员详情")
    @PostMapping(value = "/getSysUserDetails")
    public Rv getSysUserDetails(
            @ApiParam(name = "officeParam", value = "接入传参") @RequestBody OfficeParam officeParam) {
        return Rv.wrap(sysUserService.getSysUserDetails(officeParam));
    }

    /**
     * 管理员删除
     *
     * @return
     */
    @ApiOperation(value = "管理员删除", notes = "管理员删除")
    @PostMapping(value = "/getDeleteSysUser")
    public Rv getDeleteSysUser(
            @ApiParam(name = "officeParam", value = "接入传参") @RequestBody OfficeParam officeParam) {
        return Rv.wrap(sysUserService.getDeleteSysUser(officeParam));
    }

    /**
     * 管理员新增、修改
     *
     * @return
     */
    @ApiOperation(value = "管理员新增、修改", notes = "管理员新增、修改")
    @PostMapping(value = "/getUpdateSysUser")
    public Rv getUpdateSysUser(
            @ApiParam(name = "sysUserParam", value = "接入传参") @RequestBody SysUserParam sysUserParam) {
        return Rv.wrap(sysUserService.getUpdateSysUser(sysUserParam));
    }

    /**
     * 供应商新增、修改
     *
     * @return
     */
    @ApiOperation(value = "供应商新增、修改", notes = "供应商新增、修改")
    @PostMapping(value = "/getUpdateDriverManager")
    public Rv getUpdateDriverManager(
            @ApiParam(name = "param", value = "接入传参") @RequestBody SysDriverManagerParam param) {
        return sysUserService.updateDriverManager(param);
    }

    /**
     * 获取供应商列表
     *
     * @return
     */
    @ApiOperation(value = "获取供应商列表", notes = "获取供应商列表")
    @PostMapping(value = "/getDriverManagers")
    public Rv getDriverManagers(
            @ApiParam(name = "param", value = "接入传参") @RequestBody SysDriverManagerParam param) {
        return sysUserService.getDriverManagers(param);
    }

    /**
     * 获取供应商分账列表
     *
     * @return
     */
    @ApiOperation(value = "获取供应商分账列表", notes = "获取供应商分账列表")
    @PostMapping(value = "/getSupplierSeparateAccount")
    public Rv getSupplierSeparateAccount(
            @ApiParam(name = "param", value = "接入传参") @RequestBody SupplierSeparateAccountParam param) {
        return sysUserService.getSupplierSeparateAccount(param);
    }

    /**
     * 添加或更新供应商分账列表
     *
     * @return
     */
    @ApiOperation(value = "添加或更新供应商分账列表", notes = "添加或更新供应商分账列表")
    @PostMapping(value = "/addOrUpdateSupplierSeparateAccount")
    public Rv addOrUpdateSupplierSeparateAccount(
            @ApiParam(name = "param", value = "接入传参") @RequestBody List<OaSysUserSeparateAccount> param) {
        return sysUserService.addOrUpdateSupplierSeparateAccount(param);
    }
    /**
     * 根据城市获取供应商列表
     *
     * @return
     */
    @ApiOperation(value = "根据城市获取供应商列表", notes = "根据城市获取供应商列表")
    @GetMapping(value = "/getDriverManagersByCity")
    public Rv getDriverManagersByCity(@ApiParam(name = "cityId", value = "城市ID") String cityId) {
        return sysUserService.getDriverManagersByCity(cityId);
    }

    /**
     * 根据Id查看供应商信息
     */
    @ApiOperation(value = "根据Id查看供应商信息", notes = "根据Id查看供应商信息")
    @GetMapping(value = "/getDriverManagerById")
    public Rv getDriverManagerById(@ApiParam(name = "id", value = "供应商ID") String id) {
        return sysUserService.getDriverManagerById(id);
    }

    /**
     * 根据供应商id和车队，司机姓名，手机号，车牌，车型查找司机列表
     * @param id  供应商id
     * @param vehicleTeam 车队
     * @param driverName
     * @param driverPhone
     * @param vehNo
     * @param vehicleType 车辆类型(0-经济型,1-舒适性,2-豪华型,3-商务型)
     * @return
     */
    @ApiOperation(value = "根据供应商id和车队,司机姓名,手机号,车牌,车型查找司机列表", notes = "根据供应商id和车队,司机姓名,手机号,车牌,车型查找司机列表")
    @GetMapping(value = "/getDriverByManager")
    public Rv getDriverByManager(@RequestParam String id, String vehicleTeam,
                                 String driverName, String driverPhone,
                                 String vehNo,  Integer vehicleType) {
        return sysUserService.getDriverByManager(id,vehicleTeam,driverName,driverPhone,vehNo,vehicleType);
    }
}
